package com.glsc.ngateway.common.base.converter.ldap;

import com.glsc.ngateway.common.api.ldap.dto.LdapEhrCompDto;
import com.glsc.ngateway.common.base.domain.mysql.gateway.ldap.LdapEhrComp;
import org.springframework.lang.Nullable;
import org.springframework.util.CollectionUtils;

import java.util.List;
import java.util.Objects;
import java.util.stream.Collectors;

public class LdapEhrCompConverter {
    @Nullable
    public static LdapEhrComp dto2Domain(LdapEhrCompDto dto) {
        return Objects.isNull(dto) ? null : LdapEhrComp.builder()
                .id(dto.getId())
                .oaCompId(dto.getOaCompId())
                .subcompanycode(dto.getSubcompanycode())
                .subcompanydesc(dto.getSubcompanydesc())
                .companyid(dto.getCompanyid())
                .supsubcomid(dto.getSupsubcomid())
                .url(dto.getUrl())
                .showorder(dto.getShoworder())
                .canceled(dto.getCanceled())
                .subcompanyname(dto.getSubcompanyname())
                .outkey(dto.getOutkey())
                .budgetatuomoveorder(dto.getBudgetatuomoveorder())
                .ecologyPinyinSearch(dto.getEcologyPinyinSearch())
                .limitusers(dto.getLimitusers())
                .tlevel(dto.getTlevel())
                .created(dto.getCreated())
                .modified(dto.getModified())
                .modifier(dto.getModifier())
                .build();
    }

    @Nullable
    public static List<LdapEhrComp> dto2Domain(List<LdapEhrCompDto> dto) {
        return CollectionUtils.isEmpty(dto) ? null: dto.stream().map(LdapEhrCompConverter::dto2Domain).collect(Collectors.toList());
    }

    @Nullable
    public static LdapEhrCompDto domain2Dto(LdapEhrComp domain) {
        return Objects.isNull(domain) ? null : LdapEhrCompDto.builder()
                .id(domain.getId())
                .oaCompId(domain.getOaCompId())
                .subcompanycode(domain.getSubcompanycode())
                .subcompanydesc(domain.getSubcompanydesc())
                .companyid(domain.getCompanyid())
                .supsubcomid(domain.getSupsubcomid())
                .url(domain.getUrl())
                .showorder(domain.getShoworder())
                .canceled(domain.getCanceled())
                .subcompanyname(domain.getSubcompanyname())
                .outkey(domain.getOutkey())
                .budgetatuomoveorder(domain.getBudgetatuomoveorder())
                .ecologyPinyinSearch(domain.getEcologyPinyinSearch())
                .limitusers(domain.getLimitusers())
                .tlevel(domain.getTlevel())
                .created(domain.getCreated())
                .creater(domain.getCreater())
                .modified(domain.getModified())
                .modifier(domain.getModifier())
                .build();
    }

    @Nullable
    public static List<LdapEhrCompDto> domain2Dto(List<LdapEhrComp> domain) {
        return CollectionUtils.isEmpty(domain) ? null: domain.stream().map(LdapEhrCompConverter::domain2Dto).collect(Collectors.toList());
    }
}
